<template>
    <div class="defines">
        <div class="defindes-input">
            剩余期限要求:
            <el-select
                size="mini"
                v-model="riskCustomResidualMaturity.compareType"
                style="width: 60px"
                clearable
                placeholder=""
                @change="setUserDefined"
            >
                <el-option v-for="itme in selectDatas" :key="itme.id" :label="itme.name" :value="itme.id"></el-option>
            </el-select>
            <el-input v-model="riskCustomResidualMaturity.bondValue" size="mini" @change="setUserDefined">
                <template slot="append">年</template>
            </el-input>
        </div>
        <div class="defines-center">
            <p>控制值审批设置:</p>
            <el-form ref="form" label-width="120px" size="mini">
                <el-form-item label="控制值1:">
                    <el-select v-model="riskCustomApprovalTier.controlValue1" multiple @change="changOptionLeght1()">
                        <el-option
                            v-for="itme in userDefinedList"
                            :key="itme.dictKey"
                            :label="itme.dictKey + ' ' + itme.dictKeyName"
                            :value="itme.dictKey"
                            :disabled="optionconcat1"
                        ></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="控制值2:">
                    <el-select v-model="riskCustomApprovalTier.controlValue2" multiple @change="changOptionLeght2()" :disabled="concat2">
                        <el-option
                            v-for="itme in userDefinedList"
                            :key="itme.dictKey"
                            :label="itme.dictKey + ' ' + itme.dictKeyName"
                            :value="itme.dictKey"
                            :disabled="optionconcat2"
                        ></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="控制值3:">
                    <el-select v-model="riskCustomApprovalTier.controlValue3" multiple @change="setUserDefined" :disabled="concat3">
                        <el-option
                            v-for="itme in userDefinedList"
                            :key="itme.dictKey"
                            :label="itme.dictKey + ' ' + itme.dictKeyName"
                            :value="itme.dictKey"
                            :disabled="riskCustomApprovalTier.controlValue3.length >= 2"
                        ></el-option>
                    </el-select>
                </el-form-item>
                <!-- <el-form-item label="＞控制值3:">
                    <el-select v-model="riskCustomApprovalTier.controlValue4" clearable @change="setUserDefined">
                        <el-option
                            v-for="itme in userDefinedList"
                            :key="itme.dictKey"
                            :label="itme.dictKey + ' ' + itme.dictKeyName"
                            :value="itme.dictKey"
                        ></el-option>
                    </el-select>
                </el-form-item> -->
            </el-form>
        </div>
        <div class="defines-fooer">
            <p>可投余量比较逻辑设置:</p>
            <div>
                <el-tabs v-model="activeName" type="card">
                    <el-tab-pane label="法规" name="first">
                        <div class="fooer-div">
                            <el-row>
                                <el-col :span="24" class="unite-1">
                                    <el-button type="primary" @click="openVisible" :disabled="showData">编辑</el-button>
                                    <el-button type="danger" @click="deleteTableData" :disabled="showData">删除</el-button>
                                    <span class="span1">孰高孰低设置</span>
                                    <el-select
                                        style="width: 80px"
                                        size="mini"
                                        v-model="riskCustomInvest.regulationsPublicOffering.highOrLow"
                                        placeholder=""
                                        clearable
                                        @change="setUserDefined"
                                    >
                                        <el-option value="0" label="孰高"></el-option>
                                        <el-option value="1" label="孰低"></el-option>
                                    </el-select>
                                </el-col>
                                <el-col :span="24">
                                    <el-table
                                        :data="this.riskCustomInvest.regulationsPublicOffering.entryControls"
                                        tooltip-effect="dark"
                                        style="width: 100%"
                                        border
                                        size="mini"
                                        max-height="220px"
                                        @selection-change="handleSelectionChange"
                                    >
                                        <el-table-column type="selection" width="55"> </el-table-column>
                                        <el-table-column label="条目编号" width="120" prop="entryCode" fixed="left" show-overflow-tooltip>
                                        </el-table-column>
                                        <el-table-column
                                            :key="col.prop"
                                            :prop="col.prop"
                                            :label="col.title"
                                            :width="col.width"
                                            show-overflow-tooltip
                                            v-for="col in Columns"
                                        >
                                            <template slot-scope="scope">
                                                <span v-if="col.funcBody">
                                                    {{ col.funcBody(scope.row[col.prop], scope.row) }}
                                                </span>
                                                <span v-else v-html="getTbalesData(scope.row, col.prop)"></span>
                                            </template>
                                        </el-table-column>
                                    </el-table>
                                </el-col>
                                <div class="unite-dialog">
                                    <yh-dialog title="比较条目" :visible.sync="visible" width="800px" drag>
                                        <RiskTrantableSetting
                                            ref="trans"
                                            url="/entry/list/CodeOrName"
                                            index-key="entryCode"
                                            left-placeholder="编号/名称"
                                            right-placeholder="编号/名称"
                                            :columns="columnsTran"
                                            :entryType="entryType"
                                            :premise="false"
                                            :right-table-data="trantRightData"
                                            :search-names="['entryCode', 'entryName']"
                                        ></RiskTrantableSetting>
                                        <div slot="footer" class="dialog-footer">
                                            <el-button size="mini" @click="visible = false"> 取 消 </el-button>
                                            <el-button size="mini" type="primary" @click="submitSettingData">确 定 </el-button>
                                        </div>
                                    </yh-dialog>
                                </div>
                            </el-row>
                        </div>
                    </el-tab-pane>

                    <el-tab-pane label="法规专户(集合)" name="second">
                        <div class="fooer-div">
                            <el-row>
                                <el-col :span="24" class="unite-1">
                                    <el-button type="primary" @click="openSecondVisible" :disabled="showData">编辑</el-button>
                                    <el-button type="danger" @click="deleteSecondData" :disabled="showData">删除</el-button>
                                    <span class="span1">孰高孰低设置</span>
                                    <el-select
                                        style="width: 80px"
                                        size="mini"
                                        @change="setUserDefined"
                                        v-model="riskCustomInvest.regulationsOnlyDoorGather.highOrLow"
                                        placeholder=""
                                        clearable
                                    >
                                        <el-option value="0" label="孰高"></el-option>
                                        <el-option value="1" label="孰低"></el-option>
                                    </el-select>
                                </el-col>
                                <el-col :span="24">
                                    <el-table
                                        :data="this.riskCustomInvest.regulationsOnlyDoorGather.entryControls"
                                        tooltip-effect="dark"
                                        style="width: 100%"
                                        border
                                        size="mini"
                                        max-height="220px"
                                        @selection-change="handleSelectionSecond"
                                    >
                                        <el-table-column type="selection" width="55"> </el-table-column>
                                        <el-table-column label="条目编号" width="120" prop="entryCode" fixed="left" show-overflow-tooltip>
                                        </el-table-column>
                                        <el-table-column
                                            :key="col.prop"
                                            :prop="col.prop"
                                            :label="col.title"
                                            :width="col.width"
                                            show-overflow-tooltip
                                            v-for="col in Columns"
                                        >
                                            <template slot-scope="scope">
                                                <span v-if="col.funcBody">
                                                    {{ col.funcBody(scope.row[col.prop], scope.row) }}
                                                </span>
                                                <span v-else v-html="getTbalesData(scope.row, col.prop)"></span>
                                            </template>
                                        </el-table-column>
                                    </el-table>
                                </el-col>
                                <div class="unite-dialog">
                                    <yh-dialog title="比较条目" :visible.sync="secondVisible" width="800px" drag>
                                        <RiskTrantableSetting
                                            ref="seconds"
                                            url="/entry/list/CodeOrName"
                                            index-key="entryCode"
                                            left-placeholder="编号/名称"
                                            right-placeholder="编号/名称"
                                            :columns="columnsTran"
                                            :entryType="entryType"
                                            :premise="false"
                                            :right-table-data="secondRightData"
                                            :search-names="['entryCode', 'entryName']"
                                        ></RiskTrantableSetting>
                                        <div slot="footer" class="dialog-footer">
                                            <el-button size="mini" @click="secondVisible = false"> 取 消 </el-button>
                                            <el-button size="mini" type="primary" @click="submitSecondgData">确 定 </el-button>
                                        </div>
                                    </yh-dialog>
                                </div>
                            </el-row>
                        </div>
                    </el-tab-pane>

                    <el-tab-pane label="法规专户(单一)" name="third">
                        <div class="fooer-div">
                            <el-row>
                                <el-col :span="24" class="unite-1">
                                    <el-button type="primary" @click="openThirdVisible" :disabled="showData">编辑</el-button>
                                    <el-button type="danger" @click="deleteThirddData" :disabled="showData">删除</el-button>
                                    <span class="span1">孰高孰低设置</span>
                                    <el-select
                                        style="width: 80px"
                                        size="mini"
                                        @change="setUserDefined"
                                        v-model="riskCustomInvest.regulationsOnlyDoorSingle.highOrLow"
                                        placeholder=""
                                        clearable
                                    >
                                        <el-option value="0" label="孰高"></el-option>
                                        <el-option value="1" label="孰低"></el-option>
                                    </el-select>
                                </el-col>
                                <el-col :span="24">
                                    <el-table
                                        :data="riskCustomInvest.regulationsOnlyDoorSingle.entryControls"
                                        tooltip-effect="dark"
                                        style="width: 100%"
                                        border
                                        size="mini"
                                        max-height="220px"
                                        @selection-change="handleSelectionThird"
                                    >
                                        <el-table-column type="selection" width="55"> </el-table-column>
                                        <el-table-column label="条目编号" width="120" prop="entryCode" fixed="left" show-overflow-tooltip>
                                        </el-table-column>
                                        <el-table-column
                                            :key="col.prop"
                                            :prop="col.prop"
                                            :label="col.title"
                                            :width="col.width"
                                            show-overflow-tooltip
                                            v-for="col in Columns"
                                        >
                                            <template slot-scope="scope">
                                                <span v-if="col.funcBody">
                                                    {{ col.funcBody(scope.row[col.prop], scope.row) }}
                                                </span>
                                                <span v-else v-html="getTbalesData(scope.row, col.prop)"></span>
                                            </template>
                                        </el-table-column>
                                    </el-table>
                                </el-col>
                                <div class="unite-dialog">
                                    <yh-dialog title="比较条目" :visible.sync="ThirdVisible" width="800px" drag>
                                        <RiskTrantableSetting
                                            ref="thirds"
                                            url="/entry/list/CodeOrName"
                                            index-key="entryCode"
                                            left-placeholder="编号/名称"
                                            right-placeholder="编号/名称"
                                            :columns="columnsTran"
                                            :entryType="entryType"
                                            :premise="false"
                                            :right-table-data="ThirdRightData"
                                            :search-names="['entryCode', 'entryName']"
                                        ></RiskTrantableSetting>
                                        <div slot="footer" class="dialog-footer">
                                            <el-button size="mini" @click="ThirdVisible = false"> 取 消 </el-button>
                                            <el-button size="mini" type="primary" @click="submitThirdgData">确 定 </el-button>
                                        </div>
                                    </yh-dialog>
                                </div>
                            </el-row>
                        </div>
                    </el-tab-pane>
                </el-tabs>
            </div>
        </div>
    </div>
</template>
<script lang="ts">
import { Component, Prop, Vue, Watch } from 'vue-property-decorator';
import RiskTrantableSetting from '@/common/components/risk-trantable-setting.vue';
import DictionConstUtil, { SGU_CACHE } from '@/utils/diction-const-util';
import { numberFormat, unitShow } from '@/utils/tools';

@Component({
    name: 'UserDefined',
    components: {
        RiskTrantableSetting,
    },
})
export default class UserDefined extends Vue {
    @Prop() showData: boolean;
    @Prop() riskCustomSetting: any;
    @Prop() entryControl!: any;
    selectedList: any[] = [];
    activeName: string = 'first';
    entryType: any = null;
    riskCustomResidualMaturity: any = {
        tableName: '',
        columnName: '',
        compareType: '',
        bondValue: '',
    };
    riskCustomApprovalTier: any = {
        controlValue1: [],
        controlValue2: [],
        controlValue3: [],
        // controlValue4: '',
    };
    optionconcat1: boolean = false;
    optionconcat2: boolean = false;
    optionconcat3: boolean = false;
    concat2: boolean = false;
    concat3: boolean = false;
    riskCustomInvest: any = {
        regulationsPublicOffering: { highOrLow: '', entryControls: [] },
        regulationsOnlyDoorGather: { highOrLow: '', entryControls: [] },
        regulationsOnlyDoorSingle: { highOrLow: '', entryControls: [] },
    };
    Columns: any[] = [
        {
            title: '风险说明',
            prop: 'entryName',
            width: 120,
        },
        {
            title: '变动序号',
            prop: 'changeNo',
            width: 80,
        },
        {
            title: '条目标签',
            prop: 'entryTagIds',
            width: 80,
        },
        {
            title: '风险类型',
            prop: 'entryType',
            width: 130,
        },
        {
            title: '生效日期',
            prop: 'beginDate',
            width: 100,
        },
        {
            title: '失效日期',
            prop: 'endDate',
            width: 100,
        },
        {
            title: '优先级',
            prop: 'level',
            width: 65,
        },
        {
            title: '状态',
            prop: 'entryStatusValid',
            width: 50,
        },
        {
            title: '风险等级',
            prop: 'controlGrade',
            width: 85,
        },
        {
            title: '作用范围',
            prop: 'riskCalTypes',
            width: 100,
        },
        {
            title: '阈值类型1',
            prop: 'thresholdType1',
            width: 100,
        },
        {
            title: '阈值1',
            prop: 'thresholdValue1',
            width: 100,
            funcBody: (value, record) => (value != undefined ? numberFormat(value.replace(/[^\d.]/g, ''), record.unit) + unitShow(record.unit) : ''),
        },
        {
            title: '阈值类型2',
            prop: 'thresholdType2',
            width: 100,
        },
        {
            title: '阈值2',
            prop: 'thresholdValue2',
            width: 100,
            funcBody: (value, record) => (value != undefined ? numberFormat(value.replace(/[^\d.]/g, ''), record.unit) + unitShow(record.unit) : ''),
        },
        {
            title: '阈值类型3',
            prop: 'thresholdType3',
            width: 100,
        },
        {
            title: '阈值3',
            prop: 'thresholdValue3',
            width: 100,
            funcBody: (value, record) => (value != undefined ? numberFormat(value.replace(/[^\d.]/g, ''), record.unit) + unitShow(record.unit) : ''),
        },
        {
            title: '比较方向',
            prop: 'compareType',
            width: 100,
        },
        {
            title: '账户层次',
            prop: 'originalAccountId',
            width: 150,
        },
        {
            title: '控制类型',
            prop: 'accountControlType',
            width: 150,
        },
        {
            title: '控制账户',
            prop: 'accountControlValue',
            width: 150,
        },
        {
            title: '排除账户',
            prop: 'accountDebarValue',
            width: 120,
        },
        {
            title: '排除账户组',
            prop: 'accountGroupDebarValue',
            width: 150,
        },
        {
            title: '修改日期',
            prop: 'modifyDate',
            width: 120,
        },
        {
            title: '修改时间',
            prop: 'modifyTime',
            width: 100,
        },
        {
            title: '修改人',
            prop: 'modifyUser',
            width: 150,
        },
        {
            title: '条目来源',
            prop: 'sourceType',
            width: 100,
        },
        {
            title: '自定义分类',
            prop: 'customType',
            width: 110,
        },
        {
            title: '条目角色分类',
            prop: 'entryRoleCode',
            width: 180,
        },
    ];
    columnsTran = [
        {
            label: '条目编号',
            prop: 'entryCode',
            width: 100,
        },
        {
            label: '风险说明',
            prop: 'entryName',
        },
    ];
    selectDatas = [
        {
            id: '0',
            name: '>',
        },
        {
            id: '1',
            name: '<',
        },
        {
            id: '2',
            name: '≥',
        },
        {
            id: '3',
            name: '≤',
        },
        {
            id: '4',
            name: '=',
        },
        {
            id: '5',
            name: '≠',
        },
        {
            id: '6',
            name: '无效',
        },
    ];
    trantRightData: any[] = [];
    visible: boolean = false;
    fundGroups: any[] = [];
    funds: any[] = [];
    cutomTypes: any = null;
    EntryRLdata: any = {};
    Empowerment: any = {};
    stateLists: any[] = [];
    customTypesList: any[] = [];
    userDefinedList: any[] = [];

    secondVisible: boolean = false;
    secondSelectedList: any = [];
    secondRightData: any[] = [];

    ThirdVisible: boolean = false;
    ThirdRightData: any[] = [];
    ThirdSelectedList: any = [];

    async mounted() {
        console.time('UserDefined');

        // 自定义风险
        this.customTypesList = (await DictionConstUtil.FNCustomType()) || [];
        // 自定义设置
        this.userDefinedList = (await DictionConstUtil.UserDefinedCode()) || [];
        // this.userDefinedList = DictionConstUtil.PojoToList(DictionConstUtil.UserDefined);
        // 条目组
        this.funds = (await DictionConstUtil.FNFundInfo()) || [];
        // 产品组信息
        this.fundGroups = (await DictionConstUtil.FNFundGroup()) || [];
        // 自定义风险分类
        this.cutomTypes = DictionConstUtil.ListToPojo(this.customTypesList || []) || {};
        // 风险类别数据
        let entryType = await SGU_CACHE('EntryType', '/entry/entryType', []);
        let typeLocal = [];
        for (let itme of entryType) {
            let datas = itme.entryTypeId + ' ' + itme.entryTypeName;
            typeLocal.push({ label: datas, id: itme.entryTypeId });
        }
        console.timeEnd('UserDefined');
    }

    @Watch('riskCustomSetting', { immediate: true, deep: true })
    watchriskEntryBranchs() {
        console.log(this.riskCustomSetting, 'this.riskCustomSetting');

        // 判断是否有数据
        if (this.riskCustomSetting) {
            let riskData = Object.keys(JSON.parse(JSON.stringify(this.riskCustomSetting)));
            if (riskData && riskData.length > 0) {
                let maturity = this.riskCustomSetting.riskCustomResidualMaturity;
                let tier = this.riskCustomSetting.riskCustomApprovalTier;
                let invert = this.riskCustomSetting.riskCustomInvest;
                if (maturity && maturity != undefined) {
                    this.riskCustomResidualMaturity = maturity;
                }
                if (tier && tier != undefined) {
                    this.riskCustomApprovalTier = tier;
                }
                // 判断是否有数据
                let datas = Object.keys(JSON.parse(JSON.stringify(invert)));
                if (datas.length > 0 && JSON.parse(JSON.stringify(invert)) != undefined) {
                    this.riskCustomInvest = invert;
                    this.trantRightData = invert.regulationsPublicOffering.entryControls || [];
                    this.secondRightData = invert.regulationsOnlyDoorGather.entryControls || [];
                    this.ThirdRightData = invert.regulationsOnlyDoorSingle.entryControls || [];
                }
            }
            this.setUserDefined();
        }
    }

    @Watch('entryControl', { immediate: true, deep: true })
    watchentryControl() {
        if (this.entryControl.thresholdType1 && this.entryControl.thresholdType2 == '' && this.entryControl.thresholdType3 == '') {
            this.concat2 = true;
            this.concat3 = true;
        } else if (this.entryControl.thresholdType1 && this.entryControl.thresholdType2) {
            // this.riskCustomApprovalTier.controlValue1 = [];
            this.optionconcat1 = false;
            if (this.entryControl.thresholdType3) {
                // this.riskCustomApprovalTier.controlValue2 = [];
                this.optionconcat2 = false;
                this.concat2 = false;
                this.concat3 = false;
            } else {
                this.concat2 = false;
                this.concat3 = true;
            }
        }

        if (this.entryControl.thresholdType2 == '') {
            this.riskCustomApprovalTier.controlValue1 = [];
            this.riskCustomApprovalTier.controlValue2 = [];
        } else if (this.entryControl.thresholdType3 == '') {
            this.riskCustomApprovalTier.controlValue3 = [];
        }
    }

    // 处理table中的数据
    getTbalesData(data: any, props: any) {
        let fundPojo = {};
        let fundGroupPojo = {};
        // 产品信息
        let funds = this.funds;
        // 产品组信息
        let fundGroups = this.fundGroups;
        // 自定义风险分类
        let cutomTypes = this.cutomTypes;
        funds.forEach(item => {
            fundPojo[item.fundCode] = item.fundNameSt;
        });
        fundGroups.forEach(item => {
            fundGroupPojo[item.fundGroupCode] = item.fundGroupName;
        });
        // -1 也在展示范围内
        fundPojo['-1'] = '全部选择';
        fundGroupPojo['-1'] = '全部选择';
        let datas = data[props];
        if (props == 'entryType') {
            // eslint-disable-next-line no-unused-expressions
            return DictionConstUtil.EntryType[datas];
        } else if (props == 'entryStatusValid') {
            if (data[props] == true) {
                let span = '<span style="color:green">启用</span>';
                return span;
            } else {
                let span = '<span style="color:red">禁用</span>';
                return span;
            }
        } else if (props == 'controlGrade') {
            return DictionConstUtil.ControlGrade[datas];
        } else if (props == 'riskCalTypes') {
            let result = '';
            for (let i = 0; i < datas.length; i++) {
                result += DictionConstUtil.RiskCalType[datas[i]] + ',';
            }
            return result;
        } else if (props == 'thresholdType1' || props == 'thresholdType2' || props == 'thresholdType3') {
            return DictionConstUtil.ThresholdType[datas];
        } else if (props == 'compareType') {
            return DictionConstUtil.CompareDirection[datas];
        } else if (props == 'originalAccountId') {
            return DictionConstUtil.OriginalAccountType[datas];
        } else if (props == 'accountControlType') {
            return DictionConstUtil.AccountControlType[datas];
        } else if (props == 'accountDebarValue') {
            if (datas && datas.length > 0) {
                let fundNames = datas.map(item => fundPojo[item]);
                return fundNames.join(',');
            } else {
                return datas;
            }
        } else if (props == 'entryTagIds') {
            if (datas && datas.length > 0) {
                return datas.join(',');
            } else {
                return '';
            }
        } else if (props == 'accountControlValue') {
            if (datas && datas.length > 0) {
                if (String(data.originalAccountId) === '0') {
                    let fundNames = datas.map(item => fundPojo[item]);
                    return fundNames.join(',');
                } else {
                    let fundGroupNames = datas.map(item => fundGroupPojo[item]);
                    return fundGroupNames.join(',');
                }
            } else {
                return datas;
            }
        } else if (props == 'accountGroupDebarValue') {
            if (datas && datas.length > 0) {
                if (String(data.originalAccountId) === '0') {
                    let fundNames = datas.map(item => fundPojo[item]);
                    return fundNames.join(',');
                } else {
                    let fundGroupNames = datas.map(item => fundGroupPojo[item]);
                    return fundGroupNames.join(',');
                }
            } else {
                return datas;
            }
        } else if (props == 'sourceType') {
            return DictionConstUtil.SourceType[datas];
        } else if (props == 'customType') {
            return cutomTypes[datas];
        } else if (props == 'entryRoleCode') {
            if (datas != null) {
                let entryRoleCodes = datas.split(',');
                if (entryRoleCodes.length > 0 && entryRoleCodes.length === 1) {
                    return DictionConstUtil.EntryRole[datas];
                } else {
                    let name = '';
                    for (let i = 0; i < entryRoleCodes.length; i++) {
                        name += DictionConstUtil.EntryRole[entryRoleCodes[i]] + ',';
                    }
                    return name;
                }
            }
        } else {
            return datas;
        }
    }

    // 改变控制值选项长度
    changOptionLeght1() {
        if (this.riskCustomApprovalTier.controlValue1.length == 0) {
            this.optionconcat1 = false;
            return;
        }
        if (this.concat2 == true && this.concat3 == true) {
            this.optionconcat1 = false;
            if (this.riskCustomApprovalTier.controlValue1.length >= 2) {
                this.optionconcat1 = true;
            } else {
                this.optionconcat1 = false;
            }
        } else {
            if (this.riskCustomApprovalTier.controlValue1.length > 1) {
                this.optionconcat1 = false;
            } else {
                this.optionconcat1 = true;
            }
        }
        this.setUserDefined();
    }

    changOptionLeght2() {
        if (this.riskCustomApprovalTier.controlValue2.length == 0) {
            this.optionconcat2 = false;
            return;
        }
        if (this.concat3 == true) {
            this.optionconcat2 = false;
            if (this.riskCustomApprovalTier.controlValue2.length >= 2) {
                this.optionconcat2 = true;
            } else {
                this.optionconcat2 = false;
            }
        } else {
            if (this.riskCustomApprovalTier.controlValue2.length > 1) {
                this.optionconcat2 = false;
            } else {
                this.optionconcat2 = true;
            }
        }
        this.setUserDefined();
    }

    // 打开
    openVisible(): void {
        this.entryType = null;
        this.visible = true;
    }

    // 删除
    deleteTableData(): void {
        let oldTableData = this.riskCustomInvest.regulationsPublicOffering.entryControls;
        let newDataSource = [];
        for (let i = 0; i < oldTableData.length; i++) {
            if (this.selectedList.includes(oldTableData[i].entryCode)) {
                continue;
            }
            newDataSource.push(oldTableData[i]);
        }
        this.riskCustomInvest.regulationsPublicOffering.entryControls = [];
        this.riskCustomInvest.regulationsPublicOffering.entryControls = newDataSource;
        this.trantRightData = newDataSource;
        this.setUserDefined();
    }

    handleSelectionChange(val: any) {
        this.selectedList = [];
        for (let i = 0; i < val.length; i++) {
            this.selectedList.push(val[i].entryCode);
        }
    }

    submitSettingData() {
        this.visible = false;
        const rightData = (this.$refs.trans as any).getRightAllData();
        this.riskCustomInvest.regulationsPublicOffering.entryControls = rightData;
        this.trantRightData = rightData;
        this.setUserDefined();
    }

    // 法规专户
    openSecondVisible() {
        this.secondVisible = true;
    }

    deleteSecondData() {
        let oldTableData = this.riskCustomInvest.regulationsOnlyDoorGather.entryControls;
        let newDataSource = [];
        for (let i = 0; i < oldTableData.length; i++) {
            if (this.secondSelectedList.includes(oldTableData[i].entryCode)) {
                continue;
            }
            newDataSource.push(oldTableData[i]);
        }
        this.riskCustomInvest.regulationsOnlyDoorGather.entryControls = [];
        this.riskCustomInvest.regulationsOnlyDoorGather.entryControls = newDataSource;
        this.secondRightData = newDataSource;
        this.setUserDefined();
    }

    handleSelectionSecond(val: any) {
        this.secondSelectedList = [];
        for (let i = 0; i < val.length; i++) {
            this.secondSelectedList.push(val[i].entryCode);
        }
    }

    submitSecondgData() {
        this.secondVisible = false;
        const rightData = (this.$refs.seconds as any).getRightAllData();
        this.riskCustomInvest.regulationsOnlyDoorGather.entryControls = rightData;
        this.secondRightData = rightData;
        this.setUserDefined();
    }

    // 单一
    openThirdVisible() {
        this.ThirdVisible = true;
    }

    deleteThirddData() {
        let oldTableData = this.riskCustomInvest.regulationsOnlyDoorSingle.entryControls;
        let newDataSource = [];
        for (let i = 0; i < oldTableData.length; i++) {
            if (this.ThirdSelectedList.includes(oldTableData[i].entryCode)) {
                continue;
            }
            newDataSource.push(oldTableData[i]);
        }
        this.riskCustomInvest.regulationsOnlyDoorSingle.entryControls = [];
        this.riskCustomInvest.regulationsOnlyDoorSingle.entryControls = newDataSource;
        this.ThirdRightData = newDataSource;
        this.setUserDefined();
    }

    handleSelectionThird(val: any) {
        this.ThirdSelectedList = [];
        for (let i = 0; i < val.length; i++) {
            this.ThirdSelectedList.push(val[i].entryCode);
        }
    }

    submitThirdgData() {
        this.ThirdVisible = false;
        const rightData = (this.$refs.thirds as any).getRightAllData();
        this.riskCustomInvest.regulationsOnlyDoorSingle.entryControls = rightData;

        this.ThirdRightData = rightData;
        this.setUserDefined();
    }

    // 回调函数
    setUserDefined() {
        let riskCustomSetting = {
            riskCustomResidualMaturity: this.riskCustomResidualMaturity,
            riskCustomApprovalTier: this.riskCustomApprovalTier,
            riskCustomInvest: this.riskCustomInvest,
        };
        this.$emit('set-user-defined-data', riskCustomSetting);
    }
}
</script>
<style lang="scss" scoped>
.defines {
    height: 100%;
    color: #222;
    overflow-y: scroll;
    padding: 5px;

    .defindes-input {
        padding: 5px 0;
        & .el-input {
            display: inline-table;
            width: 100px;
            /deep/ .el-input-group__append {
                padding: 0 10px !important;
            }
        }
    }

    .defines-center,
    .defines-fooer {
        border: 1px solid #eee;
        border-radius: 2px;
        padding: 5px;
    }

    .defines-fooer {
        // height: 300px;

        .fooer-div {
            color: #222;

            .unite-1 {
                padding: 5px 0px;

                .span1 {
                    margin-right: 10px;
                    margin-left: 20px;
                }
            }

            .unite-dialog /deep/ .el-dialog .el-dialog__body {
                max-height: none;
                height: 66vh;
            }
        }
    }
}
</style>
